﻿using System.Collections.Generic;
using System.Xml.Serialization;

namespace Sanelib.CodeMaker
{
    public class DatabaseSchema
    {
        public string DatabaseName { get; set; }
        public string Description { get; set; }

        private List<DatabaseTableSchema> _tables;

        [XmlElement("Tables", typeof(DatabaseTableSchema))]
        public DatabaseTableSchema[] TableCollection
        {
            get
            {
                return Tables.ToArray();
            }
            set
            {
                if (value == null) return;
                _tables = new List<DatabaseTableSchema>(value);
            }
        }

        [XmlIgnore]
        public List<DatabaseTableSchema> Tables
        {
            get { return _tables ?? (_tables = new List<DatabaseTableSchema>()); }
            set { _tables = value; }
        }
    }
}